package com.common.util;

import org.apache.log4j.Logger;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ExcelCommonUtil {
    private static Logger logger = Logger.getLogger(ExcelCommonUtil.class);

    public static final String[] STORERECORD = {"equipmentCode", "postionCode", "shopCode", "shopName", "installDate", "city", "area",
            "total1", "traffic1", "environment1", "surface1", "display1", "quality1", "attitude1", "installStatus1", "sign1"};

    public static final String[] WXMCHINFO = {"id", "equipmentCode", "subAppId", "appId", "subMchId", "mchId", "industry",
            "mchName", "mchFullName", "subMchFullName", "applyTime", "key"};

    public static final String[] PLATFORMPOSITION = {"id", "postionCode", "province", "city", "area", "shop", "shopName",
            "baiduMap", "gaodeMap", "tenxunMap", "address", "baidugps", "mac", "ip"};

    public static final String[] POSITION = {"postionCode"};

    public static final String[] CONTRACTS = {"conCode", "advCode", "executeTotal", "sex", "minAge", "maxAge", "launchDate", "endDate",
            "executeNoDate", "executeOffDate", "price", "conType", "playTime"};

    public static final String[] APPVERSION = {"version", "appName", "postionCode"};

    public static final String[] EQUIPMENT = {"postionCode", "equipmentCode", "netCode", "installDate", "installBy",
            "startTime", "shutdownTime", "uploadLog", "status", "equipmentSource", "channelBusiness", "agentBusiness"};

    public static final String[] MODIFYCONTRACTS = {"id", "rltp", "advCode", "cameFrom", "equipmentCode", "triggerTime", "playDate",
            "triggerCode", "sex", "age", "postionCode", "provice", "city", "area", "faceImage"};

    public static final String[] BIDBOTTOM = {"conCode", "bidConBottom"};

    public static final String[] BIDMINTV = {"conCode", "bidConBottom"};

    public static final String[] CUSTOMERFLOW = {"equipmentCode", "trueDate", "earlyYouth", "youth", "adult", "middleAge", "oldAge",
            "earlyYouthMan", "earlyYouthWoman", "youthMan", "youthWoman", "adultMan", "adultWoman", "middleAgeMan", "middleAgeWoman", "oldAgeMan", "oldAgeWoman",
            "manTotal", "womanTotal", "total", "onlineTime"};

    public static final String[] IMPORTPOSITION = {"postionCode", "shopCode", "companyName", "shopName", "shopContacts", "shopPhone",
            "empno", "province", "city", "area", "address", "status", "shopOpen", "shopClose", "areaType", "consume",
            "flowrate", "settlement", "gps", "baiduSpot", "installDate", "areaType"};

    public static final String[] EXCEPTIONHANDLE = {"equipmentCode", "shopName", "errorDate", "errorPhenomenon","phoneCommunicationRecord", "instructorCommunicationRecord", "visitRecord", "errorReason",
            "processingMethod", "processingResult"};

    public static List<Map<String, Object>> importData(MultipartFile[] files, String[] code) throws Exception {
        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
        for (MultipartFile file : files) {
            data.addAll(ExcelUtils.getDataFromExcel(file.getInputStream(), file.getOriginalFilename(), code));
        }
        return data;
    }
}
